home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / perl5 / Glib / Object.pod < prev    next >
Encoding:
Text File  |  2007-03-05  |  11.1 KB  |  670 lines

  1. =head1 NAME
  2.  
  3. Glib::Object -  Bindings for GObject
  4.  
  5. =for position DESCRIPTION
  6.  
  7. =head1 DESCRIPTION
  8.  
  9. GObject is the base object class provided by the gobject library.  It provides
  10. object properties with a notification system, and emittable signals.
  11.  
  12. Glib::Object is the corresponding Perl object class.  Glib::Objects are
  13. represented by blessed hash references, with a magical connection to the
  14. underlying C object.
  15.  
  16. =cut
  17.  
  18.  
  19.  
  20. =head1 HIERARCHY
  21.  
  22.   Glib::Object
  23.  
  24. =for object Glib::Object Bindings for GObject
  25. =cut
  26.  
  27.  
  28.  
  29.  
  30. =head1 METHODS
  31.  
  32. =head2 object = $class->B<new> (...)
  33.  
  34. =over
  35.  
  36. =over
  37.  
  38. =item * ... (list) of key/value pairs, property values to set on creation
  39.  
  40. =back
  41.  
  42.  
  43.  
  44.  
  45. Instantiate a Glib::Object of type I<$class>.  Any key/value pairs in
  46. I<...> are used to set properties on the new object; see C<set>.
  47. This is designed to be inherited by Perl-derived subclasses (see
  48. L<Glib::Object::Subclass>), but you can actually use it to create
  49. any GObject-derived type.
  50.  
  51.  
  52. =back
  53.  
  54. =head2 scalar = Glib::Object-E<gt>B<new_from_pointer> ($pointer, $noinc=FALSE)
  55.  
  56. =over
  57.  
  58. =over
  59.  
  60. =item * $pointer (unsigned) a C pointer value as an integer.
  61.  
  62. =item * $noinc (boolean) if true, do not increase the GObject's reference count when creating the Perl wrapper.  this typically means that when the Perl wrapper will own the object.  in general you don't want to do that, so the default is false. 
  63.  
  64. =back
  65.  
  66.  
  67.  
  68.  
  69. Create a Perl Glib::Object reference for the C object pointed to by I<$pointer>.
  70. You should need this I<very> rarely; it's intended to support foreign objects.
  71.  
  72. NOTE: the cast from arbitrary integer to GObject may result in a core dump without
  73. warning, because the type-checking macro G_OBJECT() attempts to dereference the
  74. pointer to find a GTypeClass structure, and there is no portable way to validate
  75. the pointer.
  76.  
  77.  
  78. =back
  79.  
  80. =head2 unsigned = $object-E<gt>B<get_data> ($key)
  81.  
  82. =over
  83.  
  84. =over
  85.  
  86. =item * $key (string) 
  87.  
  88. =back
  89.  
  90.  
  91. Fetch the integer stored under the object data key I<$key>.  These values do not
  92. have types; type conversions must be done manually.  See C<set_data>.
  93.  
  94.  
  95. =back
  96.  
  97. =head2 $object-E<gt>B<set_data> ($key, $data)
  98.  
  99. =over
  100.  
  101. =over
  102.  
  103. =item * $key (string) 
  104.  
  105. =item * $data (scalar) 
  106.  
  107. =back
  108.  
  109.  
  110. GObject provides an arbitrary data mechanism that assigns unsigned integers
  111. to key names.  Functionality overlaps with the hash used as the Perl object
  112. instance, so we strongly recommend you use hash keys for your data storage.
  113. The GObject data values cannot store type information, so they are not safe
  114. to use for anything but integer values, and you really should use this method
  115. only if you know what you are doing.
  116.  
  117.  
  118. =back
  119.  
  120. =head2 pspec = $object_or_class_name->B<find_property> ($name)
  121.  
  122. =over
  123.  
  124. =over
  125.  
  126. =item * $name (string) 
  127.  
  128. =back
  129.  
  130. Find the definition of object property I<$name> for I<$object_or_class_name>; for
  131. the returned data see L<Glib::Object::list_properties>.
  132.  
  133. =back
  134.  
  135. =head2 $object-E<gt>B<freeze_notify> 
  136.  
  137. =over
  138.  
  139.  
  140. Stops emission of "notify" signals on I<$object>. The signals are queued
  141. until C<thaw_notify> is called on I<$object>.
  142.  
  143.  
  144. =back
  145.  
  146. =head2 list = $object-E<gt>B<get> (...)
  147.  
  148. =over
  149.  
  150. =over
  151.  
  152. =item * ... (list) list of property names
  153.  
  154. =back
  155.  
  156.  
  157. Fetch and return the values for the object properties named in I<...>.
  158.  
  159.  
  160. =back
  161.  
  162. =head2 $object->B<set> (key => $value, ...)
  163.  
  164. =over
  165.  
  166. =over
  167.  
  168. =item * ... (list) 
  169.  
  170. =back
  171.  
  172.  
  173. Set object properties.
  174.  
  175.  
  176. =back
  177.  
  178. =head2 list = $object_or_class_name->B<list_properties>
  179.  
  180. =over
  181.  
  182. =over
  183.  
  184. =back
  185.  
  186. List all the object properties for I<$object_or_class_name>; returns them as
  187. a list of hashes, containing these keys:
  188.  
  189. =over
  190.  
  191. =item name
  192.  
  193. The name of the property
  194.  
  195. =item type
  196.  
  197. The type of the property
  198.  
  199. =item owner_type
  200.  
  201. The type that owns the property
  202.  
  203. =item descr
  204.  
  205. The description of the property
  206.  
  207. =item flags
  208.  
  209. The Glib::ParamFlags of the property
  210.  
  211. =back
  212.  
  213.  
  214. =back
  215.  
  216. =head2 $object-E<gt>B<notify> ($property_name)
  217.  
  218. =over
  219.  
  220. =over
  221.  
  222. =item * $property_name (string) 
  223.  
  224. =back
  225.  
  226.  
  227. Emits a "notify" signal for the property I<$property> on I<$object>.
  228.  
  229.  
  230. =back
  231.  
  232. =head2 gpointer = $object-E<gt>B<get_pointer> 
  233.  
  234. =over
  235.  
  236.  
  237. Complement of C<new_from_pointer>.
  238.  
  239.  
  240. =back
  241.  
  242. =head2 list = $object-E<gt>B<get_property> (...)
  243.  
  244. =over
  245.  
  246. =over
  247.  
  248. =back
  249.  
  250.  
  251. Alias for C<get>.
  252.  
  253.  
  254. =back
  255.  
  256. =head2 $object->B<set_property> (key => $value, ...)
  257.  
  258. =over
  259.  
  260. =over
  261.  
  262. =back
  263.  
  264.  
  265. Alias for C<set>.
  266.  
  267.  
  268. =back
  269.  
  270. =head2 unsigned = $object_or_class_name-E<gt>B<signal_add_emission_hook> ($detailed_signal, $hook_func, $hook_data=undef)
  271.  
  272. =over
  273.  
  274. =over
  275.  
  276. =item * $detailed_signal (string) of the form "signal-name::detail"
  277.  
  278. =item * $hook_func (subroutine) 
  279.  
  280. =item * $hook_data (scalar) 
  281.  
  282. =back
  283.  
  284. Add an emission hook for a signal.  The hook will be called for any emission
  285. of that signal, independent of the instance.  This is possible only for
  286. signals which don't have the C<G_SIGNAL_NO_HOOKS> flag set.
  287.  
  288. The I<$hook_func> should be reference to a subroutine that looks something
  289. like this:
  290.  
  291.   sub emission_hook {
  292.       my ($invocation_hint, $parameters, $hook_data) = @_;
  293.       # $parameters is a reference to the @_ to be passed to
  294.       # signal handlers, including the instance as $parameters->[0].
  295.       return $stay_connected;  # boolean
  296.   }
  297.  
  298. This function returns an id that can be used with C<remove_emission_hook>.
  299.  
  300. Since 1.100.
  301.  
  302. =back
  303.  
  304. =head2 list = $instance-E<gt>B<signal_chain_from_overridden> (...)
  305.  
  306. =over
  307.  
  308. =over
  309.  
  310. =item * ... (list) 
  311.  
  312. =back
  313.  
  314.  
  315. Chain up to an overridden class closure; it is only valid to call this from
  316. a class closure override.
  317.  
  318. Translation: because of various details in how GObjects are implemented,
  319. the way to override a virtual method on a GObject is to provide a new "class
  320. closure", or default handler for a signal.  This happens when a class is
  321. registered with the type system (see Glib::Type::register and
  322. L<Glib::Object::Subclass>).  When called from inside such an override, this
  323. method runs the overridden class closure.  This is equivalent to calling
  324. $self->SUPER::$method (@_) in normal Perl objects.
  325.  
  326.  
  327. =back
  328.  
  329. =head2 unsigned = $instance-E<gt>B<signal_connect> ($detailed_signal, $callback, $data=undef)
  330.  
  331. =over
  332.  
  333. =over
  334.  
  335. =item * $detailed_signal (string) 
  336.  
  337. =item * $callback (subroutine) 
  338.  
  339. =item * $data (scalar) arbitrary data to be passed to each invocation of I<callback>
  340.  
  341. =back
  342.  
  343.  
  344.  
  345.  
  346. Register I<callback> to be called on each emission of I<$detailed_signal>.
  347. Returns an identifier that may be used to remove this handler with
  348. C<< $object->signal_handler_disconnect >>.
  349.  
  350.  
  351. =back
  352.  
  353. =head2 unsigned = $instance-E<gt>B<signal_connect_after> ($detailed_signal, $callback, $data=undef)
  354.  
  355. =over
  356.  
  357. =over
  358.  
  359. =item * $detailed_signal (string) 
  360.  
  361. =item * $callback (scalar) 
  362.  
  363. =item * $data (scalar) 
  364.  
  365. =back
  366.  
  367.  
  368. Like C<signal_connect>, except that I<$callback> will be run after the default
  369. handler.
  370.  
  371.  
  372. =back
  373.  
  374. =head2 unsigned = $instance-E<gt>B<signal_connect_swapped> ($detailed_signal, $callback, $data=undef)
  375.  
  376. =over
  377.  
  378. =over
  379.  
  380. =item * $detailed_signal (string) 
  381.  
  382. =item * $callback (scalar) 
  383.  
  384. =item * $data (scalar) 
  385.  
  386. =back
  387.  
  388.  
  389. Like C<signal_connect>, except that I<$data> and I<$object> will be swapped
  390. on invocation of I<$callback>.
  391.  
  392.  
  393. =back
  394.  
  395. =head2 retval = $object->B<signal_emit> ($name, ...)
  396.  
  397. =over
  398.  
  399. =over
  400.  
  401. =item * $name (string) the name of the signal
  402.  
  403. =item * ... (list) any arguments to pass to handlers.
  404.  
  405. =back
  406.  
  407.  
  408.  
  409.  
  410.  
  411. Emit the signal I<name> on I<$object>.  The number and types of additional
  412. arguments in I<...> are determined by the signal; similarly, the presence
  413. and type of return value depends on the signal being emitted.
  414.  
  415.  
  416. =back
  417.  
  418. =head2 $object-E<gt>B<signal_handler_block> ($handler_id)
  419.  
  420. =over
  421.  
  422. =over
  423.  
  424. =item * $handler_id (unsigned) 
  425.  
  426. =back
  427.  
  428. =back
  429.  
  430. =head2 $object-E<gt>B<signal_handler_disconnect> ($handler_id)
  431.  
  432. =over
  433.  
  434. =over
  435.  
  436. =item * $handler_id (unsigned) 
  437.  
  438. =back
  439.  
  440. =back
  441.  
  442. =head2 boolean = $object-E<gt>B<signal_handler_is_connected> ($handler_id)
  443.  
  444. =over
  445.  
  446. =over
  447.  
  448. =item * $handler_id (unsigned) 
  449.  
  450. =back
  451.  
  452. =back
  453.  
  454. =head2 $object-E<gt>B<signal_handler_unblock> ($handler_id)
  455.  
  456. =over
  457.  
  458. =over
  459.  
  460. =item * $handler_id (unsigned) 
  461.  
  462. =back
  463.  
  464. =back
  465.  
  466. =head2 integer = $instance-E<gt>B<signal_handlers_block_by_func> ($func, $data=undef)
  467.  
  468. =over
  469.  
  470. =over
  471.  
  472. =item * $func (subroutine) function to block
  473.  
  474. =item * $data (scalar) data to match, ignored if undef
  475.  
  476. =back
  477.  
  478.  
  479.  
  480. =back
  481.  
  482. =head2 integer = $instance-E<gt>B<signal_handlers_disconnect_by_func> ($func, $data=undef)
  483.  
  484. =over
  485.  
  486. =over
  487.  
  488. =item * $func (subroutine) function to block
  489.  
  490. =item * $data (scalar) data to match, ignored if undef
  491.  
  492. =back
  493.  
  494.  
  495.  
  496. =back
  497.  
  498. =head2 integer = $instance-E<gt>B<signal_handlers_unblock_by_func> ($func, $data=undef)
  499.  
  500. =over
  501.  
  502. =over
  503.  
  504. =item * $func (subroutine) function to block
  505.  
  506. =item * $data (scalar) data to match, ignored if undef
  507.  
  508. =back
  509.  
  510.  
  511.  
  512. =back
  513.  
  514. =head2 scalar = $object_or_class_name-E<gt>B<signal_query> ($name)
  515.  
  516. =over
  517.  
  518. =over
  519.  
  520. =item * $name (string) 
  521.  
  522. =back
  523.  
  524. Look up information about the signal I<$name> on the instance type
  525. I<$object_or_class_name>, which may be either a Glib::Object or a package
  526. name.
  527.  
  528. See also C<Glib::Type::list_signals>, which returns the same kind of
  529. hash refs as this does.
  530.  
  531. Since 1.080.
  532.  
  533. =back
  534.  
  535. =head2 $object_or_class_name-E<gt>B<signal_remove_emission_hook> ($signal_name, $hook_id)
  536.  
  537. =over
  538.  
  539. =over
  540.  
  541. =item * $signal_name (string) 
  542.  
  543. =item * $hook_id (unsigned) 
  544.  
  545. =back
  546.  
  547. Remove a hook that was installed by C<add_emission_hook>.
  548.  
  549. Since 1.100.
  550.  
  551. =back
  552.  
  553. =head2 $instance-E<gt>B<signal_stop_emission_by_name> ($detailed_signal)
  554.  
  555. =over
  556.  
  557. =over
  558.  
  559. =item * $detailed_signal (string) 
  560.  
  561. =back
  562.  
  563. =back
  564.  
  565. =head2 $object-E<gt>B<thaw_notify> 
  566.  
  567. =over
  568.  
  569.  
  570. Reverts the effect of a previous call to C<freeze_notify>. This causes all
  571. queued "notify" signals on I<$object> to be emitted.
  572.  
  573.  
  574. =back
  575.  
  576. =head2 boolean = Glib::Object-E<gt>B<set_threadsafe> ($threadsafe)
  577.  
  578. =over
  579.  
  580. =over
  581.  
  582. =item * $threadsafe (boolean) 
  583.  
  584. =back
  585.  
  586. Enables/disables threadsafe gobject tracking. Returns whether or not tracking
  587. will be successful and thus whether using perl ithreads will be possible. 
  588.  
  589. =back
  590.  
  591. =head2 $object-E<gt>B<tie_properties> ($all=FALSE)
  592.  
  593. =over
  594.  
  595. =over
  596.  
  597. =item * $all (boolean) if FALSE (or omitted) tie only properties for this object's class, if TRUE tie the properties of this and all parent classes.
  598.  
  599. =back
  600.  
  601.  
  602. A special method avaiable to Glib::Object derivatives, it uses perl's tie
  603. facilities to associate hash keys with the properties of the object. For
  604. example:
  605.  
  606.   $button->tie_properties;
  607.   # equivilent to $button->set (label => 'Hello World');
  608.   $button->{label} = 'Hello World';
  609.   print "the label is: ".$button->{label}."\n";
  610.  
  611. Attempts to write to read-only properties will croak, reading a write-only
  612. property will return '[write-only]'.
  613.  
  614. Care must be taken when using tie_properties with objects of types created with
  615. Glib::Object::Subclass as there may be clashes with existing hash keys that
  616. could cause infinite loops. The solution is to use custom property get/set
  617. functions to alter the storage locations of the properties.
  618.  
  619. =back
  620.  
  621.  
  622. =head1 SIGNALS
  623.  
  624. =over
  625.  
  626. =item B<notify> (Glib::Object, Glib::ParamSpec)
  627.  
  628. =back
  629.  
  630.  
  631. =head1 ENUMS AND FLAGS
  632.  
  633. =head2 flags Glib::SignalFlags
  634.  
  635.  
  636.  
  637. =over
  638.  
  639. =item * 'run-first' / 'G_SIGNAL_RUN_FIRST'
  640.  
  641. =item * 'run-last' / 'G_SIGNAL_RUN_LAST'
  642.  
  643. =item * 'run-cleanup' / 'G_SIGNAL_RUN_CLEANUP'
  644.  
  645. =item * 'no-recurse' / 'G_SIGNAL_NO_RECURSE'
  646.  
  647. =item * 'detailed' / 'G_SIGNAL_DETAILED'
  648.  
  649. =item * 'action' / 'G_SIGNAL_ACTION'
  650.  
  651. =item * 'no-hooks' / 'G_SIGNAL_NO_HOOKS'
  652.  
  653. =back
  654.  
  655.  
  656.  
  657. =head1 SEE ALSO
  658.  
  659. L<Glib>
  660.  
  661. =head1 COPYRIGHT
  662.  
  663. Copyright (C) 2003-2006 by the gtk2-perl team.
  664.  
  665. This software is licensed under the LGPL.  See L<Glib> for a full notice.
  666.  
  667.  
  668. =cut
  669.  
  670.